import { $http } from '@escook/request-miniprogram'
uni.$http = $http //这两行代码必须必放在最前面否则无效
$http.baseUrl = 'https://api-hmugo-web.itheima.net/api/public/v1'

$http.beforeRequest = function(options){
  uni.showLoading({
    title:"数据加载中..."
  })
}

// 响应拦截器
$http.afterRequest = function(){
  uni.hideLoading()
}

uni.$showMsg = function(title="数据请求失败!",duration=1500){
  uni.showToast({
    title,
    duration,
    icon:'none'
  })
}

// #ifndef VUE3
import Vue from 'vue'
import App from './App'

Vue.config.productionTip = false
App.mpType = 'app'

const app = new Vue({
    ...App,
})

app.$mount()
// #endif

// #ifdef VUE3
import { createSSRApp } from 'vue'
import * as Pinia from 'pinia';
import App from './App.vue'
export function createApp() {
  // 状态管理
  const store = Pinia.createPinia();	// 配置pinia第二句
  const app = createSSRApp(App)
  app.use(store);
  return {
    app,
    Pinia
  }
}
// #endif